#ifndef CSERIALOBJECT_H
#define CSERIALOBJECT_H

#include <QObject>
#include <QThread>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QTimer>



class CSerialObject : public QObject
{
    Q_OBJECT
public:
    explicit CSerialObject(QObject *parent = nullptr);

public slots:
    void slot_init();
    void slot_recv_data();
    void slot_send_data();
    void slot_colse();
    void slot_recv_frame(QByteArray data);

signals: //根据前面的范围域确定，也可以自己加修饰符，入 private
    void sign_send_frame(QByteArray data);

public:
    QSerialPort* qcSerialPortObj = nullptr;
    QTimer* qcTimerObj = nullptr;

private:
    int iCurRecvLen = 0; //读串口的临时变量
    int iLastRecvLen = 0;
    int iRecvLenTitle = 0; //读到的完整的串口数据长度
    QByteArray qcRecvArray;

};

#endif // CSERIALOBJECT_H
